package com.my.cd.mediator;

/**
 * 具体工作者：咖啡机
 */
public class CoffeeMachine extends Worker {

    public CoffeeMachine(String name, Mediator mediator) {
        super(name, mediator);
        mediator.register(name, this);
    }

    @Override
    public void sendMessage(int stateChange) {
        this.getMediator().receiveMessage(this.name, stateChange);
    }

    public void startCoffee() {
        System.out.println("It's time to startcoffee!");
    }

    public void finishCoffee() {
        System.out.println("After 5 minutes!");
        System.out.println("Coffee is ok!");
        sendMessage(0);
    }
}
